<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no,email=no" />
		<title>微店商品分类</title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">店铺分类</h1>
			
		</header>
		<div class="mui-content transparent"></div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/app.js"></script>
		<script>
			mui.init();
			
			var vshopid;
			
			mui.plusReady(function() {
				plus.webview.currentWebview().setStyle({scrollIndicator:'none'});
				vshopid=plus.webview.currentWebview().vshopId;
				var w=plus.nativeUI.showWaiting('',{padlock:true});
				mui.ajax(URL+'api/VShop//GetVShopCategory/'+vshopid,{
					dataType:'json',
					type:'get',
					timeout:10000,
					success:function(data){
						if(data.Success=='True'){
							if(data.ShopCategories.length>0){
								var vshopCate='<ul class="mui-table-view mui-table-view-chevron"><li class="mui-table-view-cell mui-collapse">全部分类</li>',
									vshopCateSub;
								for(var i=0; i<data.ShopCategories.length; i++){
									vshopCate+='<li class="mui-table-view-cell mui-collapse">'+
										'<a class="mui-navigate-right">'+data.ShopCategories[i].Name+'</a>';
										if(data.ShopCategories[i].SubCategories.length>0){
											vshopCate+='<ul class="mui-table-view mui-table-view-chevron">';
											var vshopCateSub='';
											for(var j=0; j<data.ShopCategories[i].SubCategories.length; j++){
												vshopCateSub+='<li class="mui-table-view-cell"><a class="mui-navigate-right vshop-category" data-id="'+data.ShopCategories[i].SubCategories[j].Id+'">'+data.ShopCategories[i].SubCategories[j].Name+'</a></li>';
											}
											vshopCate+=vshopCateSub;
											vshopCate+='</ul>'
										}
									vshopCate+='</li>';
									
								}
								vshopCate+='</ul>'
								document.getElementsByClassName('mui-content')[0].innerHTML=vshopCate;
							}else{
								var html='<div class="empty-show"><h4>该微店暂无分类</h4><button id="closeWv" class="mui-btn mui-btn-negative">去其他地方逛逛</button></div>';
					        	document.getElementsByClassName('mui-content')[0].innerHTML=html;
							}
							w.close();
				            document.getElementsByClassName("mui-content")[0].className="mui-content";
						}
					},
					error:function(xhr,type,errorThrown){
						w.close();
						reloadWvLoad();
					}
				});
				
				
				//添加列表项的点击事件
				mui('.mui-content').on('tap', '.vshop-category', function() {
					var id = this.getAttribute('data-id');
					//打开详情页面
					mui.openWindow({
						id:'vshop-search.html',
						url:'vshop-search.html',
						extras:{
							vshopId:vshopid,
							cid:id
					    },
						show: {
							autoShow:true,
							aniShow: 'pop-in'
						},
						waiting: {
							autoShow: false
						}
					});
					
				});
			});
			
		</script>
	</body>

</html>